{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [],
   "source": [
    "_audit = {}\n",
    "\n",
    "def add_audit(area, action):\n",
    "    if area in _audit:\n",
    "        _audit[area].append(action)\n",
    "    else:\n",
    "        _audit[area] = [action]\n",
    "        \n",
    "def report_audit():\n",
    "    for area, actions in _audit.items():\n",
    "        print(f\"{area} audit:\")\n",
    "        for action in actions:\n",
    "            print(f\"- {action}\")\n",
    "        print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "HR audit:\n",
      "- Hired Sam\n",
      "- Hired Tom\n",
      "\n",
      "Finance audit:\n",
      "- Used 1000£\n",
      "\n"
     ]
    }
   ],
   "source": [
    "add_audit(\"HR\", \"Hired Sam\")\n",
    "add_audit(\"Finance\", \"Used 1000£\")\n",
    "add_audit(\"HR\", \"Hired Tom\")\n",
    "report_audit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [],
   "source": [
    "import collections\n",
    "_audit = collections.defaultdict(list)\n",
    "\n",
    "def add_audit(area, action):\n",
    "    _audit[area].append(action)\n",
    "        \n",
    "def report_audit():\n",
    "    for area, actions in _audit.items():\n",
    "        print(f\"{area} audit:\")\n",
    "        for action in actions:\n",
    "            print(f\"- {action}\")\n",
    "        print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "HR audit:\n",
      "- Hired Sam\n",
      "- Hired Tom\n",
      "\n",
      "Finance audit:\n",
      "- Used 1000£\n",
      "\n"
     ]
    }
   ],
   "source": [
    "add_audit(\"HR\", \"Hired Sam\")\n",
    "add_audit(\"Finance\", \"Used 1000£\")\n",
    "add_audit(\"HR\", \"Hired Tom\")\n",
    "report_audit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [],
   "source": [
    "_audit = {}\n",
    "\n",
    "def add_audit(area, action):\n",
    "    if area not in _audit:\n",
    "        _audit[area] = [\"Area created\"]\n",
    "    _audit[area].append(action)\n",
    "        \n",
    "def report_audit():\n",
    "    for area, actions in _audit.items():\n",
    "        print(f\"{area} audit:\")\n",
    "        for action in actions:\n",
    "            print(f\"- {action}\")\n",
    "        print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "HR audit:\n",
      "- Area created\n",
      "- Hired Sam\n",
      "- Hired Tom\n",
      "\n",
      "Finance audit:\n",
      "- Area created\n",
      "- Used 1000£\n",
      "\n"
     ]
    }
   ],
   "source": [
    "add_audit(\"HR\", \"Hired Sam\")\n",
    "add_audit(\"Finance\", \"Used 1000£\")\n",
    "add_audit(\"HR\", \"Hired Tom\")\n",
    "report_audit()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [],
   "source": [
    "import collections\n",
    "_audit = collections.defaultdict(lambda: [\"Area created\"])\n",
    "\n",
    "def add_audit(area, action):\n",
    "    _audit[area].append(action)\n",
    "        \n",
    "def report_audit():\n",
    "    for area, actions in _audit.items():\n",
    "        print(f\"{area} audit:\")\n",
    "        for action in actions:\n",
    "            print(f\"- {action}\")\n",
    "        print()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "HR audit:\n",
      "- Area created\n",
      "- Hired Sam\n",
      "- Hired Tom\n",
      "\n",
      "Finance audit:\n",
      "- Area created\n",
      "- Used 1000£\n",
      "\n"
     ]
    }
   ],
   "source": [
    "add_audit(\"HR\", \"Hired Sam\")\n",
    "add_audit(\"Finance\", \"Used 1000£\")\n",
    "add_audit(\"HR\", \"Hired Tom\")\n",
    "report_audit()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3+"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
